/***** MenuPresenter.m -- Menu data display object implementation
	NeXTstep Measurement Kit
	by Alex Meyer <ameyer@phoenix.Princeton.EDU>
	for computer science senior thesis
	22 April 1992 -- created from ButtonPresenter.m
*****/

#import <stdlib.h>
#import <stdio.h>
#import <string.h>
#import <appkit/Application.h>
#import "Historian.h"
#import "MenuPresenter.h"

@implementation MenuPresenter

static id instance = nil;

+ new
{
	if (instance == nil) {
		instance = [self alloc];
		[NXApp loadNibSection:"MenuPresenter.nib"
			owner:instance];
	}
	return (instance);
}


- showData:sender
{
	NXAtom key;
	int i,tag;
	float x,y,width,height;
	char *p,*text;

	[sender copyDataTo:&rec];
	key = [sender getKey];
	for (p = key,i = 0;*p != '|';++p)
		++i;
	text = malloc(i + 1);
	strncpy(text,key,i);
	text[i] = 0;
	sscanf(p,"|%d|%f|%f|%f|%f",&tag,&x,&y,&width,&height);
	[form setStringValue:text
		at:0];
	[form setIntValue:tag
		at:1];
	[form setFloatValue:x
		at:2];
	[form setFloatValue:y
		at:3];
	[form setFloatValue:width
		at:4];
	[form setFloatValue:height
		at:5];
	[form setIntValue:rec.numHits
		at:6];			/* should be unsigned */
	[form setIntValue:rec.numCancel
		at:7];
	[form setDoubleValue:rec.timeIn
		at:8];
	[form setDoubleValue:rec.timeBetween
		at:9];
	free(text);
	[window orderFront:self];
	return self;
}


- hide:sender
{
	[window orderOut:self];
	return self;
}


- (NXAtom)identify
{
	return (NXUniqueString("Menus"));
}

@end
